package com.gan.simple_init.quartz.listener;


import com.gan.simple_init.quartz.service.SysJobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 在项目启动的时候默认开启库中的所有任务
 * @author gbw
 */
// todo 取消注释开启定时任务功能
// @Component
@Order(value = 1)
@Slf4j
public class ScheduleJobInitListener implements CommandLineRunner {

    @Resource
    SysJobService scheduleJobService;

    @Override
    public void run(String... arg0) {
        try {
            scheduleJobService.initSchedule();
        } catch (Exception e) {
        	log.error("执行" + this.getClass().getSimpleName()+ ":" + new Exception().getStackTrace()[0].getMethodName());
        }

    }

}
